<template>
  <div>
    <nuxt-child />
  </div>
</template>

<script>
import { formItemLayout } from '@/config/formItemLayout'

export default {
  name: 'Meal',
  provide: { formItemLayout },

  async fetch ({ store }) {
    const { $get } = store
    const { mealTypeNames } = store.getters.meal
    if (!$get(mealTypeNames.length)) await store.dispatch('meal/getMealType')
  },

  watch: {
    $route: {
      handler (t) { if (t.name === 'meal') this.$router.replace('/meal/manage') },
      immediate: true
    }
  }
}
</script>
